<template>
  <div>
    <r-search
      ref="search"
      :searchData="searchData"
      :searchForm="searchForm"
      :searchHandle="searchHandle"
      :inline="true"
    />

    <r-table
      :isIndex="true"
      :isPagination="true"
      :isHandle="true"
      :tableData="tableData"
      :tableCols="tableCols"
      :tablePage="pagination"
      :loading="tableLoading"
      :isSelection="false"
      @refresh="page()"
    >
    </r-table>
  </div>
</template>

<script>
export default {
  components: {},
  data() {
    return {
      orderDetail: {},
      mealCharge_detail: {},
      searchData: {
        devId: "",
        stime: "",
        etime: ""
      },
      searchForm: [
        { type: "input", placeholder: "设备编号", prop: "devId", width: 200 },
        // {
        //   type: "daterange", placeholder: "时间", prop: "date", width: 300, change: (val) => {
        //     if (val) {
        //       this.searchData.stime = val[0];
        //       this.searchData.etime = val[1];
        //     } else {
        //       this.searchData.stime = '';
        //       this.searchData.etime = '';
        //     }
        //   }
        // },
        {
          type: "date",
          placeholder: "开始日期",
          prop: "stime",
          width: 170,
          change: val => {
            this.searchData.stime = val;
          }
        },
        {
          type: "date",
          placeholder: "结束日期",
          prop: "etime",
          width: 170,
          change: val => {
            this.searchData.etime = val;
          }
        }
      ],
      searchHandle: [
        { type: "primary", label: "搜索", handle: e => this.getData() }
        // {type:'primary',label:'重置', handle: e => this.elFormSubmit(),}
      ],
      tableLoading: false,
      tableData: [],
      tableCols: [
        // { label: "ID", prop: "id", },
        { label: "设备编号", prop: "devId" },
        { label: "报警类型", prop: "typeName" },
        { label: "报警信息", prop: "alarm", overflow: true },
        { label: "提交时间", prop: "stime" }
      ],
      pagination: { limit: 10, page: 1, total: 0 }
    };
  },
  created() {
    let params = this.$route.query;
    if (params.devId) {
      this.searchData.devId = params.devId;
      // this.$message.info(`已进行搜素当前[${params.devId}]设备号`)
    }
    this.getData();
  },
  mounted() {},
  methods: {
    async getData() {
      let params = {
        id: this.searchData.id,
        devId: this.searchData.devId,
        stime: this.searchData.stime,
        etime: this.searchData.etime,
        pageNum: this.pagination.page,
        pageSize: this.pagination.limit
      };
      const res = await this.apis.alarmGetList2(params);
      if (res.code == 200) {
        this.tableData = res.rows || [];
        this.pagination.total = res.total;
      }
    },
    page() {
      this.getData();
    }
  }
};
</script>

<style scoped lang="scss"></style>
